package jjn.round1;

/**
 * @author Jiang Jining
 * @since 2023-05-14 23:58
 */
public class LeetCode11_MaxArea {
    public int maxArea(int[] height) {
        int left = 0, right = height.length - 1, result = 0;
        while (left < right) {
            int leftHeight = height[left];
            int rightHeight = height[right];
            if (leftHeight < rightHeight) {
                result = Math.max(result, leftHeight * (right - left));
                left++;
            } else {
                result = Math.max(result, rightHeight * (right - left));
                right--;
            }
        }
        return result;
    }
}
